<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../../css/aui.css">
    <link rel="stylesheet" type="text/css" href="../../css/aui-slide.css">
    <link rel="stylesheet" type="text/css" href="../../css/api.css">
    <script type="text/javascript" src="../../script/api.js"></script>
</head>

<body>
    <header class="aui-bar aui-bar-nav">
        <span class="aui-iconfont aui-icon-left aui-pull-left" onclick="api.closeFrame();">返回</span>
        <div class="aui-title">母婴用品</div>
    </header>
    <div class="aui-content aui-margin-b-15" id="goodslist">

    </div>
    <div class="aui-card-list-footer aui-text-center" id="refresh" style="display:none;">
        <span>下拉加载更多</span>
    </div>
</body>
<script type="text/javascript" src="../../script/closes.js"></script>
<!--
<script type="text/javascript">
    apiready = function() {
        var arr = new Array;
        var arr1 = new Array;
        j = 0;
        var body = {
            code: "muying",
            token: $api.getStorage('token'),
            j: j
        }
        window.openGoods = function(i) {
                api.openFrame({
                    url: '../formwork.html',
                    rect: {
                        x: 0,
                        y: 0,
                        w: 'auto',
                        h: 'auto'
                    },
                    pageParam: {
                        url: arr[i],
                        id: arr1[i],
                        token: token
                    },
                    allowEdit:true
                });
            }
            //下拉刷新功能start
        if (length != '') {
            $api.byId('refresh').style = "display:block";
            api.addEventListener({
                name: 'scrolltobottom'
            }, function(ret, err) {

                var body = {
                    code: 'muying',
                    token: $api.getStorage('token'),
                    j: j++
                }
                api.ajax({
                    url: 'http://www.mk517.com/webApi/goodslist.php',
                    method: 'post',
                    dataType: 'json',
                    "headers": {
                        "Content-Type": "application/json"
                    },
                    data: {
                        body: body
                    }
                }, function(ret, err) {
                    showGoods();
                });

            });
        } else {
            $api.byId('refresh').style = "display:none";
        }
        //下拉刷新end

        showGoods();

        function showGoods() {
            api.ajax({
                url: 'http://www.mk517.com/webApi/goodslist.php',
                method: 'post',
                dataType: 'json',
                "headers": {
                    "Content-Type": "application/json"
                },
                data: {
                    body: body
                }
            }, function(ret, err) {

                if (ret) {
                    length = ret.length;
                    $api.byId('goodsList').innerHTML = '';
                    for (var i = 0; i < ret.length; i++) {
                        data = ret[i];
                        arr.push(data.url);
                        arr1.push(data.id);
                        token = data.token;
                        $api.byId('goodsList').innerHTML +=
                            '<ul class="aui-list aui-media-list" onclick="openGoods(' + i + ');">' +
                            '<li class="aui-list-item">' +
                            '<div class="aui-media-list-item-inner">' +
                            '<div class="aui-list-item-media">' +
                            '<img src="' + data.img + '">' +
                            '</div>' +
                            '<div class="aui-list-item-inner">' +
                            '<div class="aui-list-item-text">' +
                            '<div class="aui-list-item-title">' + data.title + '</div>' +
                            '</div>' +
                            '<div class="aui-list-item-text">' +
                            '<div>已售：' + data.sell + '件&nbsp;&nbsp;&nbsp;&nbsp;<span class="aui-bg-pink" style="color:#fff;font-size:14px;">返利</span></div>' +
                            '</div>' +
                            '<div class="aui-list-item-text">' +
                            '<div><span style="color:red;font-size:20px;">￥' + data.discount_price + '</span>&nbsp; <span><s>￥' + data.price + '</s></span></div>' +
                            '</div>' +
                            '<div class="aui-list-item-text aui-pull-right">' +
                            '<a class="aui-info-item aui-btn aui-btn-warning "  onclick="openGoods(' + i + ');">去抢购</a></div></div></div></li></ul>';
                    }
                    // alert(JSON.stringify(ret));
                } else {
                    // alert(JSON.stringify(err));
                }
            });
        }


    }
</script>
-->
</html>
